package com.yx.shop.dao.impl;

import com.yx.shop.dao.ItemDao;
import com.yx.shop.entitly.Item;
import com.yx.shop.utils.JDBCUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

/**
 * @Classname ItemDaoImpl
 * @Description TODO:
 * @Date 2021/05/09 14:02
 * @Created by yx
 */
public class ItemDaoImpl implements ItemDao {
    private QueryRunner queryRunner = new QueryRunner(JDBCUtils.getDataSource());
    @Override
    public Integer addItem(Item item) {
        try {
            String sql = "insert into item values(default,?,?,?,?);";
            Object[] args = {item.getOid(),item.getPid(),item.getIcount(),item.getInum()};
            return queryRunner.update(sql,args);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
